package cn.codeforfun.dao;

import cn.codeforfun.entity.User;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
 * Package cn.codeforfun.dao
 * Project SpringBootCache
 * Author WangBin
 * Email bin.wang12@pactera.com
 * Created on 2017/6/8 15:19
 * version 1.0.0
 */
@CacheConfig(cacheNames = "users")
public interface UserDao extends JpaRepository<User, String> {

  @Cacheable(key = "#p0")
  User findByUsername(String username);

  @CachePut(key = "#p0.username")
  User save(User user);

  List<User> findAll();
}
